﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Stiggy
{
    interface Logger
    {
        void Log(Dis D);
    }

    public class ConLogger : Logger
    {
        public void Log(Dis D)
        {
            List <HammerFall> dph = D.discography;
            int temp = 0;
            for (int i = 0; i < dph.Count; i++)
            {
                switch(dph[i].GetType().ToString())
                {
                    case "Stiggy.CD1":
                        temp += ((CD1)dph[i]).leng1;
                        break;
                    case "Stiggy.CD2":
                        temp += ((CD2)dph[i]).leng2;
                        break;
                    case "Stiggy.CrimsonThunder":
                        temp += ((CrimsonThunder)dph[i]).leng;
                        break;
                    case "Stiggy.GloryToTheBrave":
                        temp += ((GloryToTheBrave)dph[i]).leng;
                        break;
                    case "Stiggy.LegacyOfKings":
                        temp += ((LegacyOfKings)dph[i]).leng;
                        break;
                    case "Stiggy.Masterpieces":
                        temp += ((Masterpieces)dph[i]).leng;
                        break;
                    case "Stiggy.Renegade":
                        temp += ((Renegade)dph[i]).leng;
                        break;
                    case "Stiggy.Threshhold":
                        temp += ((Threshhold)dph[i]).leng;
                        break;
                }
            }
            Console.WriteLine("Общая продолжительность дискографии = " + temp);
        }
    }

    public class FileLogger : Logger
    {
        public void Log(Dis D)
        {
            List<HammerFall> dph = D.discography;
            string[] s = new string[2];
            int temp = 0;
            for (int i = 0; i < dph.Count; i++)
            {
                switch (dph[i].GetType().ToString())
                {
                    case "Stiggy.CD1":
                        temp += ((CD1)dph[i]).leng1;
                        break;
                    case "Stiggy.CD2":
                        temp += ((CD2)dph[i]).leng2;
                        break;
                    case "Stiggy.CrimsonThunder":
                        temp += ((CrimsonThunder)dph[i]).leng;
                        break;
                    case "Stiggy.GloryToTheBrave":
                        temp += ((GloryToTheBrave)dph[i]).leng;
                        break;
                    case "Stiggy.LegacyOfKings":
                        temp += ((LegacyOfKings)dph[i]).leng;
                        break;
                    case "Stiggy.Masterpieces":
                        temp += ((Masterpieces)dph[i]).leng;
                        break;
                    case "Stiggy.Renegade":
                        temp += ((Renegade)dph[i]).leng;
                        break;
                    case "Stiggy.Threshold":
                        temp += ((Threshhold)dph[i]).leng;
                        break;
                }
            }
            s[0] = "Общая продолжительность дискографии = ";
            s[1] = Convert.ToString(temp);
            System.IO.File.WriteAllLines(@"temp.txt", s);


        }

    }
}
